package com.qc.head.util;

import java.io.IOException;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class BasicDao {
				
			
				public SqlSession session(){
					SqlSession session=null;
					try {
						SqlSessionFactory sf=new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis.xml"));
							session=sf.openSession();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					return session;
					
				}
				
				public void clse(SqlSession session){
					if(session != null){
						session.commit();
						session.close();
					}
					
				}
}
